<template>
  <div class="detail">
    <div class="content">
      <div class="top">
        <span class="bk">精选播客</span>
        <div>
          <span>更多</span>
          <van-icon name="arrow" />
        </div>
      </div>
      <ul class="song">
        <li v-for="(item, index) in list" :key="index" class="songDetail">
          <img :src="item.intervenePicUrl" alt="" />
          <span>{{ item.lastProgramName }}</span>
          <div class="count">
            <van-icon name="play-circle-o" />
            <span>{{ (item.id / 10000).toFixed(1) }}</span>
          </div>
        </li>
      </ul>
    </div>

    <div class="race">
      <p>排行榜</p>
      <div class="raceDetail">
        <ul>
          <li v-for="(item, index) in product" :key="index">
            <img :src="item.coverImgUrl" alt="" />
            <div>
              <span>{{ index + 1 }}.</span> <span>{{ item.name }}</span>
            </div>
            <van-icon name="minus" />
          </li>
        </ul>
      </div>
    </div>
    <p class="more" @click="show">查看更多</p>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return { list: [], product: [] };
  },
  computed: {},
  watch: {},

  methods: {
    show() {
      console.log(123);
      document.querySelector(".race").style.height = 560 + "px";
    },
    async goDetai(id) {
      //   console.log(id);

      let result = await axios.get(
        `http://localhost:3000/dj/recommend/type?type=${id}`
      );

      if (result.data.code === 200) {
        result.data.djRadios.splice(6, 1);
        this.list = result.data.djRadios;
      }
      // this.product = result.data;
    },
    async playlist() {
      let num = parseInt(Math.random() * 10);
      let result = await axios.get(
        `http://localhost:3000/top/playlist?limit=10&offset=${num}`
      );
      //   console.log(result.data);
      this.product = result.data.playlists;
      console.log(this.product);
    },
    goBack() {
      // console.log(123);
      this.$router.go(-1);
    },
  },
  created() {
    const Id = this.$route.params.id;
    console.log(this.$route.params);
    this.goDetai(Id);
    this.playlist();
  },
  mounted() {},
  components: {},
};
</script>
<style scoped>
.header {
  height: 2em;
}
.header i {
  padding-left: 0.5em;
  line-height: 2em;
}
.top {
  display: flex;
  height: 30px;
  /* position: relative; */
}
.top .bk {
  /* position: relative; */
  /* left: 2em; */
  padding-left: 2em;
  /* line-height: 1.8em; */
  font-weight: bold;
  font-size: 22px;
}
.top div {
  /* right: 2em; */
  position: relative;
  left: 45%;
  border-radius: 20px;
  border: 1px solid #000;
  padding: 0.2em;
}
.song {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  padding-top: 5px;
}
.song .songDetail {
  width: 30%;
  position: relative;
}
.song .songDetail img {
  /* display: block; */
  width: 100%;
  border-radius: 10px;
}
.songDetail span {
  display: block;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  text-align: center;
}
.count {
  display: inline;
  position: absolute;
  z-index: 999;
  top: 2px;
  right: 2px;
  color: aliceblue;
  font-size: 10px;
  background-color: #4e4c4e;
  border-radius: 10px;
}
.count span {
  display: inline;
}
.race {
  background-color: #fff;
  margin: 20px 15px 0;
  border-radius: 5px;
  height: 180px;
  overflow: hidden;
}
.race p {
  height: 30px;
  line-height: 35px;
  text-align: center;
  font-weight: bold;
}
.raceDetail ul {
  width: 100%;
}
.raceDetail ul li {
  width: 100%;
  height: 50px;
  /* line-height: 50px; */
  /* color: red; */
  position: relative;
  margin-top: 3px;
}
.raceDetail ul li img {
  width: 15%;
  height: 50px;
  border-radius: 5px;
}
.raceDetail ul li div {
  position: absolute;
  top: 0;
  left: 0;
  line-height: 50px;
  padding-left: 15%;
  /* display: inline-block; */
  /* position: relative; */
  /* top: -20px; */
  width: 65%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.raceDetail ul li i {
  /* line-height: 50px; */
  position: absolute;
  top: 18px;
  right: 30px;
}
.more {
  height: 2em;
  text-align: center;
  line-height: 2em;
  display: block;
}
</style>
